﻿<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">
 
  protected void Page_Load(object sender, EventArgs e)
  {
    //資料交換採用Server to Server(backgroup)傳送，無畫面
    string CompanyID = CommonUtil.GetRequestValue("CompanyID");
    string TrsCode = CommonUtil.GetRequestValue("TrsCode");
    string MerchantKey = CommonUtil.GetRequestValue("MerchantKey");
    string AccountNo = CommonUtil.GetRequestValue("OrderNumber");
    string CurrentOrderNo =
      string.IsNullOrEmpty(AccountNo) ? "" : "20" + AccountNo.Substring(4, 6) + "0" + AccountNo.Substring(10, 3);

    if (TrsCode == "0000")   
    {
      try
      {
        B2C_MALL_ORDER ws = new B2C_MALL_ORDER();
        ws.Url = ConfigurationManager.AppSettings["B2C_MALL_ORDER"].ToString();
        string strJson = ws.B2C_MALL_Payment_choose_WebATM_Confirm(CommonUtil.GetWebDevice(),
          HttpContext.Current.User.Identity.Name,
          CurrentOrderNo,
          AccountNo,
          TrsCode);
        JObject jObj = JsonConvert.DeserializeObject<JObject>(strJson);
        if (jObj["Is_Valid"].ToString() == "Y")
        {
          OrderInfo oi = (OrderInfo)Session["OrderInfo"];
          Session["CurrentBuyerName"] = oi.BuyerName;
          //清空購物車          
          Session.Remove("ShoppingCart");
          //清空訂單資訊
          Session.Remove("OrderInfo");
          //清空加贈
          Session.Remove("FreePlusItem");
          //清空加購
          Session.Remove("BuyPlusItem");
          //導向訂單完成                    
          //NameValueCollection data = new NameValueCollection();
          //data.Add("CurrentOrderNo", CurrentOrderNo);
          //data.Add("CurrentBuyerName", CurrentBuyerName);
          //HttpHelper.RedirectAndPOST(this.Page, Page.ResolveUrl("~/Orders/ConfirmOrder.aspx"), data);
          //return;
        }
        else
        {
          //TransactionFail(jObj["Msg"].ToString());
        }
      }
      catch (Exception)
      {
        //TransactionFail("系統下單失敗，麻煩您再試一次或重新訂購並變更付款方式，謝謝惠顧！");
      }
    }
  }

  
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title></title>
</head>
<body>
  <form id="form1" runat="server">
    <div>
    </div>
  </form>
</body>
</html>
